<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/pages/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件分页界面</title>
<s:include value="/WEB-INF/pages/common/reference.jsp" />
<bees:table-import />
<bees:paging-import />
<bees:operation-import />
<script type="text/javascript">
<!--
	function prev() {
		var action = document.forms[0].action;
		var scope = $("input[name='scope']").val();
		var path = $("input[name='path']").val();

		if (path == null || path == '' || path == '/') {
			$.ligerDialog.alert('已经是顶级目录了!');
			return;
		}

		var url = action + "?" + "scope" + "=" + scope + "&" + "path" + "=" + path.substring(0, path.lastIndexOf("/"));

		window.location.replace(url);
	}

	function next() {
		if (single()) {
			var action = document.forms[0].action;
			var scope = $("input[name='scope']").val();
			var path = $("input[type='checkbox']:checked,input[type='radio']:checked").val();
			var url = action + "?" + "scope" + "=" + scope + "&" + "path" + "=" + path;
			window.location.replace(url);
		}
	}

	function copy() {
		if (multiple()) {
			$.ligerDialog.open({
				url : "${fun:url('/backstage/io/file','paging','','scope=DIRECTORY')}",
				title : '选择器',
				width : 1024,
				height : 480,
				isResize : false,
				slide : true,
				buttons : [ {
					text : '确定',
					onclick : function(item, dialog) {
						var $form = $(dialog.frame.document.forms[0]);
						var $table = $form.find("table");
						var $checkeds = $table.find("input[type='checkbox']:checked,input[type='radio']:checked");
						if ($checkeds.length == 0) {
							$.ligerDialog.alert('请选择一条记录!');
							return;
						} else if ($checkeds.length > 1) {
							$.ligerDialog.alert('只能选择一条记录!');
							return;
						} else {
							$("input[name='path']").val($checkeds.get(0).value);
							var action = "${fun:url('/backstage/io/file','edit','copy','') }";
							document.forms[0].action = action;
							document.forms[0].submit();
							dialog.close();
						}
					}
				}, {
					text : '取消',
					onclick : function(item, dialog) {
						dialog.close();
					}
				} ]
			});
		}
	}

	function hide() {
		if (multiple()) {
			var action = "${fun:url('/backstage/io/file','edit','hide','') }";
			document.forms[0].action = action;
			document.forms[0].submit();
		}
	}

	function show() {
		if (multiple()) {
			var action = "${fun:url('/backstage/io/file','edit','show','') }";
			document.forms[0].action = action;
			document.forms[0].submit();
		}
	}
//-->
</script>
</head>
<body>
	<center>
		<div id="container">
			<s:form action="paging" namespace="/backstage/io/file">
				<s:hidden name="path" />
				<s:hidden name="scope" />
				<s:set name="action">
					${fun:url('/backstage/io/file','paging','','') }?scope=${scope }
				</s:set>
				<div id="top" style="width: 100%; height: 36px; background-color: #EAF2FE; border-bottom: 1px solid #BED5F3; position: fixed; top: 0px; left: 0px;">
					<bees:operation id="operation" style="margin-top:5px;float:left;" 
						create="${fun:url('/backstage/io/file','edit','ui','') }" 
						modify="${fun:url('/backstage/io/file','edit','ui','') }"
						remove="${fun:url('/backstage/io/file','edit','remove','') }" 
						screen="${fun:url('/backstage/io/file','paging','','') }" 
						key="file"
						buttons="[
							{type:'button',text:'上级',onclick:'javascript:prev();'},
							{type:'button',text:'下级',onclick:'javascript:next();'},
							{type:'button',text:'复制',onclick:'javascript:copy();'},
							{type:'button',text:'隐藏',onclick:'javascript:hide();'},
							{type:'button',text:'显示',onclick:'javascript:show();'}
						]" 
					/>
					<bees:location style="margin-top:5px;margin-right:5px;float:right;" 
					 	node="${node }" title="当前位置" arrow=" > " 
					 	link="{
					 		action:'${action }',
							name:'path',
							property:'path',
							text:'name'
						}" 
					/>
				</div>
				<div id="center" style="width: 100%; height: auto; margin-top: 36px; float: left;">
					<bees:table id="list" clazz="domain-table" style="width:100%;height:100%;"
						columns="[
							{name:'选中',property:'path',width:'5%',renderer:{type:'checkbox',name:'paths'}},
							{name:'名称',property:'name',width:'10%'},
							{name:'大小',property:'size()',width:'10%'},
							{name:'类型',property:'flag',width:'10%',renderer:{type:'enum',map:{true:'文件',false:'目录'}}},
							{name:'路径',property:'path',width:'30%'},
							{name:'操作',property:'id',width:'10%',renderer:{type:'operate',gap:'',links:[
								{text:'打开',action:'${action }',name:'path',property:'path'}
							]}}
						]"
						order="${page.order }" 
						by="${page.by }" 
						domains="${page.domains }" 
					/>
				</div>
			</s:form>
		</div>
	</center>
</body>
</html>